package com.cjq.green.constant;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Getter
public enum EndPointConstant {
    DEFAULT("cn-shanghai","green-cip.cn-shanghai.aliyuncs.com"),
    SHENZHEN("cn-shenzhen","green-cip.cn-shenzhen.aliyuncs.com"),
    SHANGHAI("cn-shanghai","green-cip.cn-shanghai.aliyuncs.com"),
    BEIJING("cn-beijing","green-cip.cn-beijing.aliyuncs.com"),
    HANGZHOU("cn-hangzhou"," green-cip.cn-hangzhou.aliyuncs.com");


    private final String region;
    private final String endPoint;

    EndPointConstant(String region,String endPoint){
        this.region = region;
        this.endPoint = endPoint;
    }


    public static EndPointConstant getEndPoint(String region) {
        if (region==null||region.isEmpty()){
            log.warn("接入区域参数不存在，请检查（已返回默认值:'SHANGHAI'）");
            return DEFAULT;
        }
        for (EndPointConstant endPointConstant : EndPointConstant.values()){
            if (region.equalsIgnoreCase(endPointConstant.getRegion())){
                return endPointConstant;
            }
        }
        return DEFAULT;
    }
}
